﻿// JScript source code
$(document).ready(function () {
    function regMatchStr(reg, str) {
        if (reg.test(str)) {
            return RegExp.$1.toLowerCase();
        }
        return "";
    }
    var currLink = document.location.href;
    if (currLink !== 'undefined') {
        var regControl = /http\:\/\/[^\/]+\/(.+)/i;
        if (regControl.test(currLink)) {
            var relativeUrl = RegExp.$1;
            var controller = regMatchStr(/(^[^\/\?]+)/i, relativeUrl);
            var viewer = regMatchStr(/(?:\/)([^\/\?]+)/i, relativeUrl);
            if (controller == "itservice") {
                if (viewer != "breakdownindex") {
                    $("#VNavParent2").addClass('VNavParentI').removeClass('VNavParentII_B')
                    $("#VNavParent1").children("ul").show();
                    switch (viewer) {
                        case "desktopindex":
                            $("#DeskTopIndex").addClass("ui-icons VNavLeaf_a");
                            break;
                        case "vpnindex":
                            $("#VPNIndex").addClass("ui-icons VNavLeaf_a");
                            break;
                        case "networkaccessindex":
                            $("#NetworkAccessIndex").addClass("ui-icons VNavLeaf_a");
                            break;
                        case "antivirusindex":
                            $("#AntiVirusIndex").addClass("ui-icons VNavLeaf_a");
                            break;
                        case "appsystemindex":
                            $("#AppSystemIndex").addClass("ui-icons VNavLeaf_a");
                            break;
                        case "businessindex":
                            $("#BusinessIndex").addClass("ui-icons VNavLeaf_a");
                            break;
                        case "internalindex":
                            $("#InternalIndex").addClass("ui-icons VNavLeaf_a");
                            break;
                    }
                }
                else {
                    $("#VNavParent1").addClass('VNavParentI').removeClass('VNavParentII_B')
                    $("#VNavParent2").addClass('VNavParentII_B').removeClass('VNavParentI')
                    $("#VNavParent2").children("ul").show();
                    $("#BreakDownIndex").addClass("ui-icons VNavLeaf_a");
                }
            }
            else {
                switch (viewer) {
                    case "scheduledworklist":
                        $("#VNavParent2").addClass('VNavParentI').removeClass('VNavParentII_B')
                        $("#VNavParent1").addClass('VNavParentII_B').removeClass('VNavParentI')
                        $("#VNavParent1").children("ul").show();
                        $("#ScheduledWorkList").addClass("ui-icons VNavLeaf_a");
                        break;
                    case "worklisthistory":
                        $("#VNavParent2").addClass('VNavParentI').removeClass('VNavParentII_B')
                        $("#VNavParent1").addClass('VNavParentII_B').removeClass('VNavParentI')
                        $("#VNavParent1").children("ul").show();
                        $("#WorklistHistory").addClass("ui-icons VNavLeaf_a");
                        break;
                    case "myworklist":
                        $("#VNavParent1").addClass('VNavParentI').removeClass('VNavParentII_B')
                        $("#VNavParent2").addClass('VNavParentII_B').removeClass('VNavParentI')
                        $("#VNavParent2").children("ul").show();
                        $("#MyWorklist").addClass("ui-icons VNavLeaf_a");
                        break;
                    case "mydraft":
                        $("#VNavParent1").addClass('VNavParentI').removeClass('VNavParentII_B')
                        $("#VNavParent2").addClass('VNavParentII_B').removeClass('VNavParentI')
                        $("#VNavParent2").children("ul").show();
                        $("#MyDraft").addClass("ui-icons VNavLeaf_a");
                        break;
                }
            }
        }

    }
});

var VNavParent = function (obj) {
    $(obj).children("ul").slideToggle(300);
    VP_down_className = $(obj).attr('class');
    if (VP_down_className == 'ui-icons VNavParentI') {
        $(obj).addClass('VNavParentII_B').removeClass('VNavParentI')

    } else {
        $(obj).addClass('VNavParentI').removeClass('VNavParentII_B')
    }
}
var newBtn = function (obj) {
    $("#newRelease").slideToggle(300);
    return false;
}
var hotBtn = function (obj) {
    $("#hotOnline").slideToggle(300);
    return false;
}
var s2_blue = function (obj) {
    s2_blue_className = $(obj).attr('class');
    if (s2_blue_className == 's2_blue') {
        $(obj).addClass('s2_blue_B').removeClass('s2_blue');
        s2_blue_p_className = $(obj).children("p").attr('class');
        if (s2_blue_p_className == 'ui-icons s2_blue_1') {
            $(obj).children("p").addClass('s2_blue_1_B').removeClass('s2_blue_1');
        }
        if (s2_blue_p_className == 'ui-icons s2_blue_2') {
            $(obj).children("p").addClass('s2_blue_2_B').removeClass('s2_blue_2');
        }
        if (s2_blue_p_className == 'ui-icons s2_blue_3') {
            $(obj).children("p").addClass('s2_blue_3_B').removeClass('s2_blue_3');
        }

    } else {
        $(obj).addClass('s2_blue').removeClass('s2_blue_B');
        s2_blue_p_className = $(obj).children("p").attr('class');
        if (s2_blue_p_className == 'ui-icons s2_blue_1_B') {
            $(obj).children("p").addClass('s2_blue_1').removeClass('s2_blue_1_B');
        }
        if (s2_blue_p_className == 'ui-icons s2_blue_2_B') {
            $(obj).children("p").addClass('s2_blue_2').removeClass('s2_blue_2_B');
        }
        if (s2_blue_p_className == 'ui-icons s2_blue_3_B') {
            $(obj).children("p").addClass('s2_blue_3').removeClass('s2_blue_3_B');
        }
    }
}
var s2_green = function (obj) {
    s2_green_className = $(obj).attr('class');
    if (s2_green_className == 's2_green') {
        $(obj).addClass('s2_green_B').removeClass('s2_green');
        s2_green_p_className = $(obj).children("p").attr('class');
        if (s2_green_p_className == 'ui-icons s2_green_1') {
            $(obj).children("p").addClass('s2_green_1_B').removeClass('s2_green_1');
        }
        if (s2_green_p_className == 'ui-icons s2_green_2') {
            $(obj).children("p").addClass('s2_green_2_B').removeClass('s2_green_2');
        }
        if (s2_green_p_className == 'ui-icons s2_green_3') {
            $(obj).children("p").addClass('s2_green_3_B').removeClass('s2_green_3');
        }

    } else {
        $(obj).addClass('s2_green').removeClass('s2_green_B');
        s2_green_p_className = $(obj).children("p").attr('class');
        if (s2_green_p_className == 'ui-icons s2_green_1_B') {
            $(obj).children("p").addClass('s2_green_1').removeClass('s2_green_1_B');
        }
        if (s2_green_p_className == 'ui-icons s2_green_2_B') {
            $(obj).children("p").addClass('s2_green_2').removeClass('s2_green_2_B');
        }
        if (s2_green_p_className == 'ui-icons s2_green_3_B') {
            $(obj).children("p").addClass('s2_green_3').removeClass('s2_green_3_B');
        }
    }
}
//$(document).ready(function(){
//    $("#VNavParent2").mouseenter(function () {
//        $("#VNavParent2").addClass("VNavParentII");
//        $("#VNavParent2").removeClass("VNavParentI");

//    });
//    $("#VNavParent2").mouseleave(function () {
//        $("#VNavParent2").addClass("VNavParentI");
//        $("#VNavParent2").removeClass("VNavParentII");
//    });

//});

function ConvertJSONDateToJSDateObject(jsondate) {
    var date = new Date(parseInt(jsondate.replace("/Date(", "").replace(")/", ""), 10));
    return getDateTime(date);
}

function getDateTime(date) {
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var day = date.getDate();
    var hh = date.getHours();
    var mm = date.getMinutes();
    var ss = date.getSeconds();
    return year + "/" + month + "/" + day + " " + hh + ":" + mm + ":" + ss;
}